oncontext Event |
This event is fired when the element, to which shortcut menu is attached, is right-clicked.
Syntax
Inline HTML |
<div cordysType = ="wcp.library.ui.ContextMenu " id =contextMenuID oncontext="handler()"...> ... </div> |
Event Information
To invoke |
Define the function call on the shortcut menu and right-click the HTML element to which a shortcut menu is attached. |
Default Action |
Initiates any action associated with this event. This event will get cancelled when the event'sreturnValueproperty is set to 'false'. |
Event Object Properties
Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.
Property |
Description |
|---|---|
activeElement |
Read-only. Object that denotes the HTML element to which the shortcut menu is attached. |
returnValue |
Variant that sets one of the following values.
|
Example
The following example shows how the event is used to cancel the display of the shortcut menu.
<!-- Context menu definition inside the BODY tag -->
<div cordysType = ="wcp.library.ui.ContextMenu " id="myContext" oncontext="show()">
<div id="hello">Say Hello</div>
</div>
//Display the item on which shortcut menu is attached and cancel the event
function show()
{
application.notify("Element : " + application.event.activeElement.outerHTML);
application.event.returnValue = false;
}
The following example shows how the event is used to disable one menu item of the shortcut menu based on a condition.
<!-- Context menu definition inside the BODY tag -->
<div cordysType = ="wcp.library.ui.ContextMenu " id="permissions" oncontext="show()">
<div id="readPermission">Allow Read</div>
<div id="writePermission">Allow Write</div>
</div>
//Disable write permissions if the global variable "permit" is set to false
function show()
{
if (permit == false)
{
var item = document.all['writePermission'];
item.enabled = "false";
}
}